#!/usr/bin/env node


import http from 'http';
import chalk from 'chalk';

const server = http.createServer((req, res) => {
  // 打印请求起始行
  console.log(chalk.greenBright(`${req.method} ${req.url} HTTP/${req.httpVersion}`));

  // 发送响应
  res.writeHead(200, { 'Content-Type': 'text/plain' });
  res.end('Hello, world!\n');
});

server.listen(8080, () => {
  console.log(chalk.greenBright(`Server running at http://localhost:8080/`));
});